Skip to content

fix(malloc): harden pprof output for Pyroscope malloc profiles#24197

Open
VioletQwQ-0 wants to merge 2 commits intomatrixorigin:mainfrom
VioletQwQ-0:violet/malloc-pyroscope-pr
Open

fix(malloc): harden pprof output for Pyroscope malloc profiles#24197
VioletQwQ-0 wants to merge 2 commits intomatrixorigin:mainfrom
VioletQwQ-0:violet/malloc-pyroscope-pr

Conversation

@VioletQwQ-0
Copy link
Copy Markdown

Summary

This PR hardens MatrixOne's custom /debug/malloc pprof output for Pyroscope ingestion.

Changes:

  • rename malloc profile sample types to Go heap-style names:
    • alloc_objects
    • alloc_space
    • inuse_objects
    • inuse_space
  • populate pprof metadata in Profiler.Write:
    • PeriodType
    • Period
    • TimeNanos
    • Mapping.HasFunctions
  • explicitly bind every emitted profile.Location to the default profile.Mapping
  • strengthen malloc pprof tests with:
    • profile.Parse(...)
    • p.CheckValid()
    • non-nil Location.Mapping assertions
  • update regression TKE template to include [malloc] config for tp / dn

Why

We previously observed that:

  • /debug/malloc was parseable by go tool pprof
  • Pyroscope could discover malloc profile types
  • but agent/backend ingest could still fail with nil pointer dereference

The remaining MatrixOne-side compatibility gap appeared to be Location.Mapping == nil in the emitted profile.

Validation

Repository-side:

  • malloc pprof round-trip/validity test added and strengthened

Cluster-side:

  • isolated TKE validation using the forked build from this change
  • malloc profile types visible in Pyroscope API
  • CN/DN series queryable
  • stacktrace/flamegraph data queryable
  • previous nil-pointer ingest failure did not reproduce in short-window validation

Notes

The cluster-side result suggests Location.Mapping was the main MatrixOne-side compatibility issue for custom malloc profile ingest. Longer soak / overhead validation is still planned separately in mo-auto-test.

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 24, 2026

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

- Rename sample types to alloc_objects, alloc_space, inuse_objects, inuse_space; default inuse_space
- Set PeriodType, Period, TimeNanos, and Mapping.HasFunctions in Profiler.Write
- Add heap_profiler_pprof_test for profile.Parse round-trip
- Add [malloc] block to mo_checkin_regression_tke.yaml for tp/dn

Made-with: Cursor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants